//
//  switchVC.m
//  Notification
//
//  Created by Apple on 2017/3/22.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "switchVC.h"
#import "HongFile.pch"
@interface switchVC ()

@end

@implementation switchVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"UIButtonVC";
    self.view.backgroundColor = [UIColor whiteColor];

    self.but = [UIButton buttonWithType:UIButtonTypeCustom];
    self.but.frame = CGRectMake(SCREEN_WIDTH/2-40, 480, 80, 30);
    self.but.layer.borderWidth = 1;
    self.but.layer.borderColor = [UIColor grayColor].CGColor;
    [self.but setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.but setTitle:@"Change" forState:UIControlStateNormal];
#pragma mark-按钮选中时的状态
    [self.but setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
    [self.but addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.but];
    
    self.ima = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"picture1.jpg"]];
    self.ima.frame = CGRectMake(SCREEN_WIDTH/2-100, 100, 200, 300);
    self.ima.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.ima];
    
    self.lab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-100, 420, 200, 40)];
    self.lab.textAlignment = NSTextAlignmentCenter;
    self.lab.text = @"picture";
    self.lab.layer.borderWidth = 1;
    self.lab.layer.borderColor = [UIColor blackColor].CGColor;
    [self.view addSubview:self.lab];
}
-(void)buttonClick:(UIButton*)button{
    BOOL isOn = [self.lab.text isEqualToString:@"picture"];
    if (isOn) {
        self.lab.text = @"图片";
        self.ima.image = [UIImage imageNamed:@"picture2.jpg"];
    }else{
        self.lab.text = @"picture";
        self.ima.image = [UIImage imageNamed:@"picture1.jpg"];
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
